home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / 422mods.zip / TOP10.422 < prev    next >
Text File  |  1993-02-23  |  9KB  |  281 lines

  1. //TOP10 Mod for WWIV v4.22 . . .
  2. Dr. Dre #1 @1 7-=1Top Administrator7=-0
  3. Mon Feb 22 07:03:20 1993
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │ Mod Name: Top10 .MOD       Mod Authors: Sledgehammer 1@4654 WWIVnet AC     │
  6. │ Difficulty: Easy                  Date: January 21,1993                    │
  7. │ WWIV Version: 4.22  - but should work on just about any... once you find   │
  8. │               where it's supposed to go in bbs.c                           │
  9. │ Files Affected: bbs.c                                                      │
  10. │ Description: This mod will print out top 10 leachers, posters, uploaders   │
  11. │              and also the users who have spent the most time online.       │
  12. └────────────────────────────────────────────────────────────────────────────┘
  13. Discalimer:   If you do regular BACK UPS you won't ever have problems.  But if
  14.               do email me and I will help you the best I can.  The mod works
  15.               perfect with my bbs...
  16.  
  17.  
  18. STEP 1:
  19.  
  20. Open up BBS.c and add the followong void just before void mainmenu.
  21.  
  22.  
  23. void top_ten_lists()
  24. {
  25.     userrec u;
  26.     int i,i1,stop,num_users,ok,j;
  27.  
  28.     int             low_posts_on_list,
  29.                     low_logons_on_list,
  30.                     store_int,
  31.                     posts_per_user[10],
  32.                     logons_per_user[10],
  33.                     flag,
  34.                     last;
  35.  
  36.     unsigned long   up_k_per_user[10],
  37.                     dn_k_per_user[10],
  38.                     store_lng;
  39.  
  40.     float           timeon_per_user[10],
  41.                     store_flt;
  42.  
  43.     char s[5][10][31],
  44.          ch,
  45.          store_chr[31];
  46.  
  47.     for (i = 0; i < 10; i++) {
  48.         posts_per_user[i]  = 0;
  49.         logons_per_user[i] = 0;
  50.         up_k_per_user[i]   = 0;
  51.         dn_k_per_user[i]   = 0;
  52.         timeon_per_user[i] = 0;
  53.     }
  54.     num_users = number_userrecs();
  55.     npr("%2d Total Users",num_users);
  56.     ok = 0;
  57.  
  58. /* Initialize Variables with Default Values */
  59.  
  60.     for (i = 0; i < 5; i++)
  61.         for (i1 = 0; i1 < 10; i1++)
  62.             strcpy(s[i][i1], "None");
  63.  
  64. /* Get the 10 Highest Values From the Userlists */
  65.  
  66.     for( i=1; i<=num_users; i++ )
  67.     {
  68.         read_user( i, &u );
  69.         stop = posts_per_user[0];
  70.         j = 0;
  71.         for( i1=1; i1<10; i1++ )
  72.             if( posts_per_user[i1] < stop )
  73.             {
  74.                 j = i1;
  75.                 stop = posts_per_user[i1];
  76.             }
  77.         if( u.msgpost > stop )
  78.         {
  79.             posts_per_user[j] = u.msgpost;
  80.             strcpy( s[0][j], nam(&u, i ) );
  81.         }
  82.         stop = logons_per_user[0];
  83.         j = 0;
  84.         for( i1=1; i1<10; i1++ )
  85.             if( logons_per_user[i1] < stop )
  86.             {
  87.                 j = i1;
  88.                 stop = logons_per_user[i1];
  89.             }
  90.         if( u.logons > stop )
  91.         {
  92.             logons_per_user[j] = u.logons;
  93.             strcpy( s[1][j], nam(&u, i ) );
  94.         }
  95.         store_lng = up_k_per_user[0];
  96.         j = 0;
  97.         for( i1=1; i1<10; i1++ )
  98.             if( up_k_per_user[i1] < store_lng )
  99.             {
  100.                 j = i1;
  101.                 store_lng = up_k_per_user[i1];
  102.             }
  103.         if( u.uk > store_lng )
  104.         {
  105.             up_k_per_user[j] = u.uk;
  106.             strcpy( s[2][j], nam(&u, i ) );
  107.         }
  108.         store_lng = dn_k_per_user[0];
  109.         j = 0;
  110.         for( i1=1; i1<10; i1++ )
  111.             if( dn_k_per_user[i1] < store_lng )
  112.             {
  113.                 j = i1;
  114.                 store_lng = dn_k_per_user[i1];
  115.             }
  116.         if( u.dk > store_lng )
  117.         {
  118.             dn_k_per_user[j] = u.dk;
  119.             strcpy( s[3][j], nam(&u, i ) );
  120.         }
  121.         store_flt = timeon_per_user[0];
  122.         j = 0;
  123.         for( i1=1; i1<10; i1++ )
  124.             if( timeon_per_user[i1] < store_flt )
  125.             {
  126.                 j = i1;
  127.                 store_flt = timeon_per_user[i1];
  128.             }
  129.         if( u.timeon > store_flt )
  130.         {
  131.             timeon_per_user[j] = u.timeon;
  132.             strcpy( s[4][j], nam(&u, i ) );
  133.         }
  134.     }
  135.  
  136. /* Fix the Timeon to minutes instead of seconds. */
  137.  
  138.     for( i=0; i < 10; i++ )
  139.         timeon_per_user[i] = ( timeon_per_user[i] / 60 );
  140. /*
  141.         Sort Data 
  142. */
  143.     for( j = 0; j < 10; j++ )
  144.         for( i = j+1; i < 10; i++ )
  145.         {
  146.             if( posts_per_user[i] > posts_per_user[j] )
  147.             {
  148.             store_int = posts_per_user[i];
  149.             posts_per_user[i] = posts_per_user[j];
  150.             posts_per_user[j] = store_int;
  151.             strcpy(store_chr, s[0][i]);
  152.             strcpy(s[0][i], s[0][j]);
  153.             strcpy(s[0][j], store_chr);
  154.            }
  155.            
  156.            if( logons_per_user[i] > logons_per_user[j] )
  157.            {
  158.             store_int = logons_per_user[i];
  159.             logons_per_user[i] = logons_per_user[j];
  160.             logons_per_user[j] = store_int;
  161.             strcpy(store_chr, s[1][i]);
  162.             strcpy(s[1][i], s[1][j]);
  163.             strcpy(s[1][j], store_chr);
  164.            }
  165.            
  166.            if( up_k_per_user[i] > up_k_per_user[j] )
  167.            {
  168.             store_lng = up_k_per_user[i];
  169.             up_k_per_user[i] = up_k_per_user[j];
  170.             up_k_per_user[j] = store_lng;
  171.             strcpy(store_chr, s[2][i]);
  172.             strcpy(s[2][i], s[2][j]);
  173.             strcpy(s[2][j], store_chr);
  174.            }
  175.            
  176.            if( dn_k_per_user[i] > dn_k_per_user[j] )
  177.            {
  178.             store_lng = dn_k_per_user[i];
  179.             dn_k_per_user[i] = dn_k_per_user[j];
  180.             dn_k_per_user[j] = store_lng;
  181.             strcpy(store_chr, s[3][i]);
  182.             strcpy(s[3][i], s[3][j]);
  183.             strcpy(s[3][j], store_chr);
  184.            }
  185.            
  186.            if( timeon_per_user[i] > timeon_per_user[j] )
  187.            {
  188.             store_flt = timeon_per_user[i];
  189.             timeon_per_user[i] = timeon_per_user[j];
  190.             timeon_per_user[j] = store_flt;
  191.             strcpy(store_chr, s[4][i]);
  192.             strcpy(s[4][i], s[4][j]);
  193.             strcpy(s[4][j], store_chr);
  194.            }
  195.         }          
  196.  
  197.     nl();
  198.     do {
  199.         npr("\r\nTop 10 Lists for %s!\r\n\n",syscfg.systemname);
  200.         prt(1,"1) Posts"); nl();
  201.         prt(2,"2) Logons"); nl();
  202.         prt(3,"3) K Uploaded"); nl();
  203.         prt(4,"4) K Downloaded"); nl();
  204.         prt(5,"5) Total Time on"); nl();
  205.         prt(6,"Q) Quit"); nl();nl();
  206.         prt(7,"Which (1-5,Q) ? ");
  207.         ch = onek("Q12345");
  208.         nl();
  209.         switch(ch) {
  210.             case 'Q':
  211.                 ok = 1;
  212.                 break;
  213.             case '1':
  214.                 prt(3,"Highest number of posts");
  215.                 nl();nl();
  216.                 npr("##  Posts  Name\r\n");
  217.                 for (i = 0; i < 10; i++)
  218.                     npr("%2d. %-3d    %s\r\n",
  219.                         i+1,
  220.                         posts_per_user[i],
  221.                         s[0][i]);
  222.                 break;
  223.             case '2':
  224.                 prt(3,"Highest Number of Logons");
  225.                 nl();nl();
  226.                 npr("##  Logons  Name\r\n");
  227.                 for (i = 0; i < 10; i++)
  228.                     npr("%2d. %-3d    %s\r\n",
  229.                         i+1,
  230.                         logons_per_user[i],
  231.                         s[1][i]);
  232.                 break;
  233.             case '3':
  234.                 prt(3,"Most K Uploaded (Sledge's BEST)");
  235.                 nl();nl();
  236.                 npr("##  Up K     Name\r\n");
  237.                 for (i = 0; i < 10; i++)
  238.                     npr("%2d. %-5ld    %s\r\n",
  239.                         i+1,
  240.                 up_k_per_user[i],
  241.                 s[2][i]);
  242.                 break;
  243.             case '4':
  244.                 prt(3,"Most K LEACHED");
  245.                 nl();nl();
  246.                 npr("##  Down K   Name\r\n");
  247.                 for (i = 0; i < 10; i++)
  248.                     npr("%2d. %-5ld    %s\r\n",
  249.                     i+1,
  250.                     dn_k_per_user[i],
  251.                     s[3][i]);
  252.                 break;
  253.             case '5':
  254.                 prt(3,"Most time spent online");
  255.                 nl();nl();
  256.                 npr("##  Time On   Name\r\n");
  257.                 for (i = 0; i < 10; i++)
  258.                     npr("%2d. %-6.0f    %s\r\n",
  259.                         i+1,
  260.                         timeon_per_user[i],
  261.                         s[4][i]);
  262.                 break;
  263.         }
  264.     } while ((!hangup) && (!ok));
  265. }
  266.  
  267. STEP 2:
  268.  
  269. Add the following two lines in void mainmenu..
  270.  
  271.  
  272.   if ((strcmp(s,"UPLOAD")==0) && (actsl>10))
  273.     upload_post();
  274.   if (strcmp(s,"TOP10")==0)   /*add*/
  275.     top_ten_lists();          /*add*/
  276.  
  277.  
  278. STEP 3:
  279.  
  280. Add  //top10 to your menu and recompile!
  281.